package top.soulblack.purchasesale.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import top.soulblack.purchasesale.model.GoodsUnit;

import java.util.List;

@Mapper
public interface GoodsUnitMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(GoodsUnit record);

    int insertSelective(GoodsUnit record);

    GoodsUnit selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(GoodsUnit record);

    int updateByPrimaryKey(GoodsUnit record);

    @Select("select * from goods_unit order by sort")
    List<GoodsUnit> selectAll();

    @Insert("insert into goods_unit (name, sort) values (#{name}, #{sort})")
    void addUnit(GoodsUnit goodsUnit);

    @Select("select count(*) from goods_unit where name = #{name}")
    int existUnit(String name);

}